<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <input type="text" id = "a">
  <span id = "b"></span>
  <script>
    var obj = {};
    Object.defineProperty(obj,'hello',{
      set(newVal) {
        document.getElementById('a').value = newVal;
        document.getElementById('b').innerHTML = newVal;
        console.log('属性被监听');
      }
    })
    document.addEventListener('keyup',function(e) {
      obj.hello = e.target.value;
    })
    console.log(obj);
  </script>

</body>
</html>